<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>电影主页</title>
    <%- include common %>
    <style>
        .mysearch {
            display: flex;
        }
    </style>
</head>

<body>
    <%- include("head",{title:"mav",username}) %>
    <div class="container container-fluid">
        <h2 class="h2 text-danger">电影主页</h2>
        <div class="row">
            <div class="col col-md-6">
                <button class="btn btn-primary" onclick="location.href='/mav?year=1'">年份升序 1</button>
                <button class="btn btn-success" onclick="location.href='/mav?year=-1'">年份降序 -1 </button>
                <button class="btn btn-info" onclick="location.href='/mav?rating.average=1'">评分升序 1</button>
                <button class="btn btn-danger" onclick="location.href='/mav?rating.average=-1'">评分降序 -1 </button>
            </div>
            <div class="col col-md-6">
                <div class="form-group mysearch">
                    <input type="text" id="keyword" class="form-control" placeholder="请输入关键字">
                    <button class="btn btn-warning" onclick="getSearchResult()">点击搜索</button>
                </div>
            </div>
        </div>
        <div class="row">
            <%    result.forEach((item,index)=>{   %>
            <div class="col-md-3 col-sm-3 col-xs-3 ">
                <div class="thumbnail">
                    <a href="<%- '/comment/index?mid='+item.id %>">
                        <img style="height:320px;width:100%;" src="<%- item.images.large.replace(/img7/,'img3') %>"
                            class="" alt="">
                    </a>
                    <h4 class="text-primary pull-right"><%- item.year %></h4>
                    <h4 class="text-danger"><%- item.title %></h4>
                    <p class="text-success">评分: <%- item.rating.average %></p>
                    <p class="text-info">分类: <%- item.genres %></p>
                    <p class="text-warning">导演: <%- item.directors&&item.directors[0].name %></p>
                </div>
            </div>
            <%   })    %>

        </div>

    </div>
    <%- include foot %>

    <script>
        //传入搜索的数据
        function getSearchResult() {
            window.location.href = "/mav?keyword=" + $("#keyword").val();
        }
    </script>

</body>

</html>